<?php if (!defined('insite')) die("no access"); 
require "opt.php";
unset($ntime);
$ntime = @filemtime("_dat/cach/".$_SESSION["lang"]."_quickinfo"); 
if (!$ntime or time()- $ntime >$config["qstatistic"])
{
  $list = explode(",",$config["qinfo_list"]);
	ob_start();
	$content = new content();
	$content->out_content("theme/".$config["theme"]."/them/qinfo_h.them");
	$content->set('|write|', online_time);
	$content->set('|value|', "<span id='srvtime' >&nbsp;</span>");
	$content->out_content("theme/".$config["theme"]."/them/qinfo_c.them");
	if(in_array("online",$list))
	{
	
		/*
		* online/max box
		*/
		$sql = $db->fetchrow($db->query("SELECT Ovalue FROM MWC"));
		$maxconnect = $sql[0]; 
		
		if ($check=@fsockopen($config["ser_host"],$config["port"],$ERROR_NO,$ERROR_STR,(float)0.3)) 
		{
			fclose($check); 
			$sql = $db->numrows( $db->query("SELECT memb___id FROM MEMB_STAT WHERE ConnectStat !=0 "));
			($sql== "")? $sql=0:"";
			$statusQ="<span class='succes'>Online</span>";	
			if ($sql > $maxconnect) 
			{
				$maxconnect = $sql;
				$db->query ("UPDATE MWC SET Ovalue='".$maxconnect."'");
				$connected ="<span style='color:#65c40a'>".$sql."(".$maxconnect.")</span>";
			}else $connected= "<span style='color:#65c40a'>".$sql."(".$maxconnect.")</span>";
		}
		else
		{
			$connected ="<font color='red'>0(".$maxconnect.")</font>";
			$statusQ ="<span class='warnms'>Offline</span>";
		}
		unset ($sql); 
		$content->set('|write|', online_msg);
		$content->set('|value|', $connected);
		$content->out_content("theme/".$config["theme"]."/them/qinfo_c.them");
		$content->set('|write|', online_status);
		$content->set('|value|', $statusQ);
		$content->out_content("theme/".$config["theme"]."/them/qinfo_c.them");
	}
	if (in_array("24online",$list))
	{
	 /**
	 * online for 24 hours
	 **/
	 $month_today = date("M", time());
	 $day_today = date("j", time());
         $year_today = date("Y", time());
         $online_today = $db->fetchrow($db->query("SELECT count(*) FROM MEMB_STAT WHERE ConnectTM LIKE '%".$month_today."%".$day_today."%".$year_today."%' OR DisConnectTM LIKE '%".$month_today."%".$day_today."%".$year_today."%'"));
	 $content->set('|write|', online_today);
	 $content->set('|value|', $online_today[0]);
	 $content->out_content("theme/".$config["theme"]."/them/qinfo_c.them");
	}
	if(in_array("accs",$list))
	{
		/*
		* Accounts
		*/
		 ($sql = $db->fetchrow($db->query("SELECT Count(memb___id) FROM memb_info"))) ? $accnum = $sql[0] : $accnum = 0;
		  unset ($sql);
		$content->set('|write|', online_accnum);
		$content->set('|value|', $accnum);
		$content->out_content("theme/".$config["theme"]."/them/qinfo_c.them");
	}

	if(in_array("chars",$list))
	{
		/*
		* Characters
		*/
		 ($sql = $db->fetchrow($db->query("SELECT Count(Name) FROM character"))) ? $charnum = $sql[0] : $charnum = 0;
		  unset ($sql);
		$content->set('|write|', online_charnum);
		$content->set('|value|', $charnum);
		$content->out_content("theme/".$config["theme"]."/them/qinfo_c.them");
	}

	if(in_array("guild",$list))
	{
		/*
		* Guilds
		*/
		 ($sql = $db->fetchrow($db->query("SELECT Count(G_Name) FROM guild"))) ? $guildnum = $sql[0] : $guildnum = 0;
		  unset ($sql);
		$content->set('|write|', online_guilds);
		$content->set('|value|', $guildnum);
		$content->out_content("theme/".$config["theme"]."/them/qinfo_c.them");
	}

	if(in_array("cs",$list))
	{
		/*
		* Castle
		*/
		 $cs_info = know_csstate();
		 $castle="<a href='".$config["siteaddress"]."/?p=cs' class='forumnick' style='font-family:Arial;fonti-size:10px;' title='Castle Siege: ".$cs_info[1]."<br> Begin in: ".$cs_info[2]."<br> End in: ".$cs_info[3]."'>".$cs_info [0]."</a>";
		 $content->set('|write|', online_castle);
		 $content->set('|value|', $castle);
		 $content->out_content("theme/".$config["theme"]."/them/qinfo_c.them");
	}

	if(in_array("cw",$list))
	{
		/*
		* CryWolf
		*/
		$sql = $db->fetchrow($db->query("SELECT CRYWOLF_STATE from ".$config["CW_table"].""));
		($sql[0] == 1) ? $crywolf = '<span style="color:green;font-size:10px;">'.online_crywolf_1.'</span>' : $crywolf = '<span style="color:red;font-size:10px;">'.online_crywolf_0.'</span>';
		unset ($sql);
		$content->set('|write|', online_crywolf);
		$content->set('|value|', $crywolf);
		$content->out_content("theme/".$config["theme"]."/them/qinfo_c.them");
	}

	
	
	$content->out_content("theme/".$config["theme"]."/them/qinfo_f.them");
	
		$content = ob_get_contents();
		write_catch ("_dat/cach/".$_SESSION["lang"]."_quickinfo",$content);
		ob_end_clean();	  echo $content;
	}
	else require '_dat/cach/'.$_SESSION["lang"].'_quickinfo';